package com.hefeng.wx.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hefeng.wx.domain.WxUser;

import com.hefeng.wx.mapper.WxUserMapper;
import com.hefeng.wx.service.WxUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Service
public class WxUserServiceImpl extends ServiceImpl<WxUserMapper, WxUser> implements WxUserService {
    @Autowired
    WxUserMapper wxUserDao;
    @Override
    public WxUser getWxuserById(String wxOpenId) {
        LambdaQueryWrapper<WxUser> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(WxUser::getWxOpenId,wxOpenId);
        return wxUserDao.selectOne(queryWrapper);
    }

    @Override
    public Map saveResident(WxUser wxUser) {
        Map<String,Object>map=new HashMap<>();
        try {
            wxUser.setWxState(1);
            wxUser.setWxUserType(2);
            wxUser.setCreatedTime(new Date());
            int make=wxUserDao.insert(wxUser);
            map.put("userId",wxUser.getUserId());
            //添加成功后推送到燃气接口
            if(make>0){

            }
        }catch (Exception e){
            map.put("data","");
        }
        return map;

    }


}
